<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div th:replace="XAdmin/commons/header"></div>
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
<style>
    [v-cloak] {
        display: none;
    }
</style>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">预定信息</a>
                <a>
                    <cite>预定设置</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="x-body" id="app">
        <br><br><br>
        <form class="layui-form layui-form-pane" id="add">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <br>
                    <div class="layui-inline layui-form-item">
                        <label class="layui-form-label"> <span class='x-red'>*</span>可预定时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="reserveTime" id="reserveTime"
                                   lay-verify="required" placeholder="可预定时间" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-inline layui-form-item">
                        <label class="layui-form-label"> <span class='x-red'>*</span>可预定人数</label>
                        <div class="layui-input-inline">
                            <input type="number" min="0" name="reserveNumber"
                                   lay-verify="required" placeholder="可预定人数" class="layui-input">
                        </div>
                    </div>
                    <br>
                    <br>
                    <br>
                    <br>
                    <br>
                    <br>
                    <div style="text-align: center" class="layui-form-item">
                        <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                            保存
                        </button>
                    </div>
                    <div style="height:100px;"></div>
                </div>

            </div>

        </form>
    </div>
</div>

</body>

<script>
    layui.use(['laydate', 'form'],
        function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#reserveTime', //指定元素
                trigger: 'click',
                type: 'date',
            });
        });

    layui.use(['form', 'layer'],
        function () {
            var form = layui.form;
            var layer = layui.layer;

            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    let form = data.field;
                    form.userId = $userId;

                    let request = {
                        url: 'reserveSetting/addReserveSetting',
                        data: JSON.stringify(form),
                        method: "post",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 20000) {
                            layer.alert("操作成功", {
                                    icon: 6
                                },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.reload();


                                });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    });
                    return false;
                });
        });


</script>
</html>